﻿#include "housemanagecontent.h"
#include "ui_housemanagecontent.h"
#include <QMessageBox>

HouseManageContent::HouseManageContent(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::HouseManageContent)
{
    ui->setupUi(this);

    m_house = GlobalVars::g_localHouse;
    initWindowUnits();
}

HouseManageContent::~HouseManageContent()
{
    delete ui;
}

void HouseManageContent::initWindowUnits()
{
    ui->lb_houseType->setText(m_house.getType());
    ui->lb_price->setText("¥" + QString::number(m_house.getPrice()));
}

void HouseManageContent::setImages(const QImage &image)
{
    ui->lb_image->setPixmap(QPixmap::fromImage(image.scaled(120,100)));
}

const QString &HouseManageContent::getHouseType()
{
    return m_house.getType();
}

void HouseManageContent::setHouseImage(const QImage& image)
{
    ui->lb_image->setPixmap(QPixmap::fromImage(image.scaled(120,100)));
}

void HouseManageContent::on_pb_watchDetails_clicked()
{
    emit signalWatchHouseTypeInfo(m_house);
}

void HouseManageContent::on_pb_delete_clicked()
{
    QMessageBox::StandardButton result = QMessageBox::warning(this,
                                 "警告",
                                 "确定要删除吗？",
                                 QMessageBox::Yes | QMessageBox::Cancel,
                                 QMessageBox::Cancel);

    if (result == QMessageBox::Yes)
    {
        emit signalDeleteHouseTypeInfo(m_house.getHouse());
    }
}
